home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / text / info / gif_specs.pp / gif_specs
Text File  |  1994-11-17  |  23KB  |  562 lines

  1.  
  2.  
  3.  
  4.                                   G I F
  5.  
  6.                        Graphics Interchange Format
  7.  
  8.  
  9.  
  10.  
  11.                      A standard defining a mechanism
  12.                     for the storage and transmission
  13.                   of raster-based graphics information
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.                                May 1, 1987
  37.  
  38.  
  39.  
  40.  
  41.                     (c) CompuServe Incorporated, 1987
  42.                            All rights reserved
  43.  
  44.  
  45.  
  46.                          CompuServe Incorporated
  47.                        5000 Arlington Centre Blvd.
  48.                           Columbus, Ohio 43220
  49.                              (614) 457-8600
  50.                                                                    Page 2
  51.  
  52.  
  53.        CompuServe Graphics Interchange Format (GIF) Specification
  54.  
  55.  
  56.                             Table of Contents
  57.  
  58.         INTRODUCTION . . . . . . . . . . . . . . . . . page 3
  59.  
  60.         GENERAL FILE FORMAT  . . . . . . . . . . . . . page 3
  61.  
  62.         GIF SIGNATURE  . . . . . . . . . . . . . . . . page 4
  63.  
  64.         SCREEN DESCRIPTOR  . . . . . . . . . . . . . . page 4
  65.  
  66.         GLOBAL COLOR MAP . . . . . . . . . . . . . . . page 4
  67.  
  68.         IMAGE DESCRIPTOR . . . . . . . . . . . . . . . page 5
  69.  
  70.         LOCAL COLOR MAP  . . . . . . . . . . . . . . . page 6
  71.  
  72.         RASTER DATA  . . . . . . . . . . . . . . . . . page 6
  73.  
  74.         GIF TERMINATION  . . . . . . . . . . . . . . . page 7
  75.  
  76.         APPENDIX A - GLOSSARY  . . . . . . . . . . . . page 8
  77.  
  78.         APPENDIX B - INTERACTIVE SEQUENCES . . . . . . page 9
  79.  
  80.         APPENDIX C - IMAGE PACKAGING & COMPRESSION . . page 11
  81. Graphics Interchange Format (GIF)                                  Page 3
  82. Specification
  83.  
  84.  
  85. INTRODUCTION
  86.  
  87.         'GIF' is CompuServe's standard  for  defining  generalized  color
  88.    raster    images.    This   'Graphics   Interchange   Format'   allows
  89.    high-quality, high-resolution graphics to be displayed on a variety of
  90.    graphics hardware and is intended as an exchange and display mechanism
  91.    for graphics images.  The image format described in this  document  is
  92.    designed  to  support  current and future image technology and will in
  93.    addition serve as a basis for future CompuServe graphics products.
  94.  
  95.         The main focus of this  document  is  to  provide  the  technical
  96.    information  necessary  for a programmer to implement GIF encoders and
  97.    decoders.  As such,  some  assumptions  are  made  as  to  terminology
  98.    relavent to graphics and programming in general.
  99.  
  100.         The first section of this document describes the GIF data  format
  101.    and  its  components  and  applies  to  all  GIF  decoders,  either as
  102.    standalone programs or as part of a communications package.   Appendix
  103.    B  is a section relavent to decoders that are part of a communications
  104.    software package and describes the protocol requirements for  entering
  105.    and  exiting  GIF  mode,  and  responding  to  host interrogations.  A
  106.    glossary in Appendix A defines some of the terminology  used  in  this
  107.    document.  Appendix C gives a detailed explanation of how the graphics
  108.    image itself is packaged as a series of data bytes.
  109.  
  110.  
  111.                Graphics Interchange Format Data Definition
  112.  
  113.  
  114.  GENERAL FILE FORMAT
  115.  
  116.         +-----------------------+
  117.         | +-------------------+ |
  118.         | |   GIF Signature   | |
  119.         | +-------------------+ |
  120.         | +-------------------+ |
  121.         | | Screen Descriptor | |
  122.         | +-------------------+ |
  123.         | +-------------------+ |
  124.         | | Global Color Map  | |
  125.         | +-------------------+ |
  126.         . . .               . . .
  127.         | +-------------------+ |    ---+   
  128.         | |  Image Descriptor | |       |   
  129.         | +-------------------+ |       |   
  130.         | +-------------------+ |       |  
  131.         | |  Local Color Map  | |       |-   Repeated 1 to n times
  132.         | +-------------------+ |       |   
  133.         | +-------------------+ |       |   
  134.         | |    Raster Data    | |       |   
  135.         | +-------------------+ |    ---+   
  136.         . . .               . . .   
  137.         |-    GIF Terminator   -|   
  138.         +-----------------------+
  139. Graphics Interchange Format (GIF)                                  Page 4
  140. Specification
  141.  
  142.  
  143.  GIF SIGNATURE
  144.  
  145.         The following GIF Signature identifies the data  following  as  a
  146.    valid GIF image stream.  It consists of the following six characters:
  147.  
  148.              G I F 8 7 a
  149.  
  150.         The last three characters '87a' may be viewed as a version number
  151.    for  this  particular  GIF definition and will be used in general as a
  152.    reference  in  documents  regarding  GIF  that  address  any   version
  153.    dependencies.
  154.  
  155.  SCREEN DESCRIPTOR
  156.  
  157.         The Screen Descriptor describes the overall  parameters  for  all
  158.    GIF  images following.  It defines the overall dimensions of the image
  159.    space or logical screen  required,  the  existance  of  color  mapping
  160.    information,  background  screen  color,  and color depth information.
  161.    This information is stored in a series of  8-bit  bytes  as  described
  162.    below.
  163.  
  164.               bits
  165.         7 6 5 4 3 2 1 0  Byte #
  166.         +---------------+
  167.         |               |  1
  168.         +-Screen Width -+      Raster width in pixels (LSB first)
  169.         |               |  2
  170.         +---------------+
  171.         |               |  3
  172.         +-Screen Height-+      Raster height in pixels (LSB first)
  173.         |               |  4
  174.         +-+-----+-+-----+      M = 1, Global color map follows Descriptor
  175.         |M|  cr |0|pixel|  5   cr+1 = # bits of color resolution
  176.         +-+-----+-+-----+      pixel+1 = # bits/pixel in image
  177.         |   background  |  6   background=Color index of screen background
  178.         +---------------+          (color is defined from the Global color
  179.         |reserved (zero)|  7        map or default map if none specified)
  180.         +---------------+
  181.  
  182.  
  183.  GLOBAL COLOR MAP
  184.  
  185.         The Global Color Map is optional but recommended for images where
  186.    accurate  color rendition is desired.  The existence of this color map
  187.    is indicated in the 'M' field of byte 5 of the Screen  Descriptor.   A
  188.    color  map  can  also  be associated with each image in a GIF file but
  189.    will normally use this global map because of hardware restrictions  in
  190.    equipment  available  today.   In the individual Image Descriptors the
  191.    'M' flag will normally be zero.  If the Global Color Map  is  present,
  192.    it's definition immediately follows the Screen Descriptor.  The number
  193.    of color map  entries  following  a  Screen  Descriptor  is  equal  to
  194.    2**(# bits per pixel),  where each entry consists of three byte values
  195.    representing  the  relative  intensities  of  red,  green   and   blue
  196.    respectively.  Each pixel value received is displayed according to its
  197. Graphics Interchange Format (GIF)                                  Page 5
  198. Specification
  199.  
  200.  
  201.    closest match with an available color on the  display  based  on  this
  202.    color  map.   The  color  components  represent a fractional intensity
  203.    value from none (0) to full (255).   White  would  be  represented  as
  204.    (255,255,255), black as (0,0,0) and medium yellow as (180,180,0).  For
  205.    display, if the device supports fewer than 8 bits per color component,
  206.    the  higher order bits of each component are used.  In the creation of
  207.    a GIF color map entry with hardware supporting fewer than 8  bits  per
  208.    component,  the  component values for the hardware should be converted
  209.    to the 8-bit format with the following calculation:
  210.  
  211.         <map_value> = <component_value>*255/(2**<nbits> -1)
  212.  
  213.         This assures accurate translation of colors for all displays.  If
  214.    no  Global  Color  Map  is indicated, a default color map is generated
  215.    internally which maps each incoming color index to  a  hardware  color
  216.    index.
  217.  
  218.  
  219.  IMAGE DESCRIPTOR
  220.  
  221.         The Image Descriptor defines the actual placement and extents  of
  222.    the following image within the space defined in the Screen Descriptor.
  223.    Also defined are flags to indicate  the  presence  of  a  local  color
  224.    lookup  map,  and  to  define  the pixel display sequence.  Each Image
  225.    Descriptor is introduced by an image separator character.  The role of
  226.    the  Image  Separator is